<?
include_once("database_info.php");
include_once("common.php");
connect_select_test($_POST['table']);
if ($_POST['key'] == crypt("He1sR1sen", $_POST['key'])){
	if ($_POST['cols']){
		$array = explode("|col|", $_POST['cols']);	
	} else {
		$cols = mysql_query("DESC `".$_POST['table']."`");
		for ($x=0;$x<mysql_num_rows($cols);$x++){
			$array[] = "";
		}
	}
	for ($x=0;$x<count($array);$x++){
		$array[$x] = mysql_real_escape_string($array[$x]);
	}
	$query = "INSERT INTO `".$_POST['table']."` values('".implode("', '", $array)."')";
	if (mysql_query($query)){
		$query = "SELECT `id` FROM `".$_POST['table']."` ORDER BY `id` DESC LIMIT 0,1";
		$id = mysql_query($query);
		if ($id){
			echo "Success.".mysql_result($id, 0);
		} else {
			echo "Could not fetch new ID";
		}
	} else {
		echo "Error\n".$query;
	}
}
?>